package itbour.onetouchshow.widget.inching;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import itbour.onetouchshow.R;
import itbour.onetouchshow.constants.AppConst;
import itbour.onetouchshow.utils.UIUtils;

/**
 * Created by zjl_d on 2017/11/29.
 */

public class InchingOperaPW extends PopupWindow {


    private final TextView tvTextDelete;
    private final TextView tvImgEdit;
    private final TextView tvImgDelete;
    private final TextView tvTabEdit;
    private final TextView tvTabDelete;
    private final TextView tvTabColor;
    private final LinearLayout llTextOpera;
    private final LinearLayout llImgOpera;
    private final LinearLayout llTabOpera;
    OnPwTabOnClick onPwTabOnClick;
    private TextView tvTextEdit;


    public InchingOperaPW(Context context) {
        super(context);

        //初始化DragSortGridLayout
        View inflate = View.inflate(context, R.layout.inching_opera_popwindow, null);
        setContentView(inflate);
        setFocusable(false);
        setOutsideTouchable(false);
        setBackgroundDrawable(new ColorDrawable());
        //设置PopupWindow弹出窗体的宽
        this.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
        //设置PopupWindow弹出窗体的高
        this.setHeight(UIUtils.dip2px(30));

        tvTextEdit = inflate.findViewById(R.id.tv_text_edit);

        tvTextEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onPwTabOnClick.onTabClick(AppConst.PW_TV_EDIT);
            }
        });
        tvTextDelete = inflate.findViewById(R.id.tv_text_delete);
        tvTextDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onPwTabOnClick.onTabClick(AppConst.PW_TV_DEL);
            }
        });
        tvImgEdit = inflate.findViewById(R.id.tv_img_edit);
        tvImgEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onPwTabOnClick.onTabClick(AppConst.PW_IMG_EDIT);
            }
        });

        tvImgDelete = inflate.findViewById(R.id.tv_img_delete);
        tvImgDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onPwTabOnClick.onTabClick(AppConst.PW_IMG_DEL);
            }
        });
        tvTabEdit = inflate.findViewById(R.id.tv_tab_edit);
        tvTabEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onPwTabOnClick.onTabClick(AppConst.PW_TAB_EDIT);
            }
        });

        tvTabDelete = inflate.findViewById(R.id.tv_tab_delete);
        tvTabDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onPwTabOnClick.onTabClick(AppConst.PW_TAB_DEL);
            }
        });
        tvTabColor = inflate.findViewById(R.id.tv_tab_color);
        tvTabColor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onPwTabOnClick.onTabClick(AppConst.PW_TAB_COLOR);
            }
        });

        llTextOpera = inflate.findViewById(R.id.ll_text_opera);
        llImgOpera = inflate.findViewById(R.id.ll_img_opera);
        llTabOpera = inflate.findViewById(R.id.ll_tab_opera);


    }

    public void showTextType() {
        llTextOpera.setVisibility(View.VISIBLE);
        llImgOpera.setVisibility(View.GONE);
        llTabOpera.setVisibility(View.GONE);
    }

    public void showImgType() {
        llTextOpera.setVisibility(View.GONE);
        llImgOpera.setVisibility(View.VISIBLE);
        llTabOpera.setVisibility(View.GONE);
    }

    public void showTabType() {
        llTextOpera.setVisibility(View.GONE);
        llImgOpera.setVisibility(View.GONE);
        llTabOpera.setVisibility(View.VISIBLE);
    }

    public void setFontStyleListener(OnPwTabOnClick onItemPlayClick) {
        this.onPwTabOnClick = onItemPlayClick;
    }

    public interface OnPwTabOnClick {
        void onTabClick(String type);
    }
}
